<template>
    <div class="widgets bg-white">
        <div class="btn-group left">
            <el-button type="danger" disabled>作废</el-button>
            <el-button type="warning" disabled>发邮件</el-button>
            <el-button type="success" disabled>发微信</el-button>
            <el-button type="primary" disabled>发QQ</el-button>
        </div>
        <div class="btn-group right">
            <el-button type="info">刷新</el-button>
            <el-button type="primary" @click="add">新增</el-button>
            <el-button type="danger" v-if="multipleSelection.length <= 0" disabled>删除</el-button>
            <el-button type="danger" v-else @click="del">删除</el-button>
            <el-button type="primary" disabled>附件</el-button>
            <el-button-group class="btn-other">
                <el-button v-if="multipleSelection.length <= 0" disabled>
                    <img src="../../../assets/images/export.png" alt="">
                </el-button>
                <el-button title="导出" v-else>
                    <img src="../../../assets/images/export.png" alt="">
                </el-button>
                <el-button title="导入">
                    <el-upload class="upload-demo" :action="$url" :show-file-list="false" multiple style="display: inline-block;">
                        <img src="../../../assets/images/import.png" alt="">
                    </el-upload>
                </el-button>                 
                <el-button title="打印">
                    <img src="../../../assets/images/print.png" alt="">
                </el-button>
                <el-button title="帮助">
                    <img src="../../../assets/images/help.png" alt="">
                </el-button>
            </el-button-group>
        </div>
    </div>
</template>
<script>
export default {
    data() {
        return {
            multipleSelection: this.$store.state.borrowOrderStore.multipleSelection,
            selectRowId: this.$store.state.borrowOrderStore.selectRowId
        }
    },
    methods: {
        add() {
            this.$store.commit('borrowOrderStore/updateRowId');
            this.$util.openLayerIframe({title: '借款单-新增', zIndex: 13, width: '85%', height: '85%', url: this.$domain + '/#/financial/borrowOrder/form'});
        },
        del() {         //删除表格数据
            this.$confirm('确定删除选中单据？', '删除提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                var type = {
                    headers: {
                        'Content-Type': 'application/json'
                    }
                }
                this.$http.post('borrowingForm/deleteBorrowingForm', JSON.stringify(this.selectRowId), type).then(res => {
                    if(res.data.code == 20001) {
                        this.$message({message: '删除成功', type: 'success', duration: 1500});
                        setTimeout(() => {
                            this.$store.dispatch('borrowOrderStore/getOrderTableDataByBtnStutas');
                        }, 1000);
                    } else {
                        this.$message.error(res.data.msg || '删除失败');
                    }
                })
            }).catch(() => {
                this.$message({message: '已取消删除', type: 'info', duration: 1500});
            });
        }
    }
}
</script>